<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script>
			
			function hashUniq(arr) {
			  let hashTable = arr.reduce((result, curr, index, array) => {
			    result[curr] = true;
			    return result;
			  }, {})
			  return Object.keys(hashTable).map(item => parseInt(item, 10));
			}
			/**
			 * 数组对象去重根据摸一个属性去重
			 * @param {Object} arr
			 * @param {Object} field
			 */
			function removeRepeat(arr, field){
			    let s = [], result = {}, reSet = {}
			    for(let v of arr){
			        s.push(v[field])
			    }
			    for(let i=0,len=s.length;i<len;i++){
			        if(!result[s[i]] && result[s[i]] !== 0) {
			           result[s[i]] = i
			        } else {
			          reSet[s[i]] = i
			        }
			    }
			    for(let key in reSet){
			        arr.splice(reSet[key], 1)
			    }
			    return arr
			}
			
			
			let ar=['1','2','3','4','2','5','1'];
			let par=[{
			    _id: 123,
			    name: '张三'
			},{
			    _id: 124,
			    name: '李四'
			},{
			    _id: 123,
			    name: '张三'
			}]
			//console.log(hashUniq(ar))
			console.log(removeRepeat(par,'_id'))
		</script>
	</body>
</html>
